<?php

using("njoy.data.persistence.*");
using("njoy.web.ui.*");

class DefaultLayout extends Layout
{
	public $slogan;
	public $menu;

	public function Load()
	{
		$this->slogan = $this->PrepareSlogan();
		$this->menu = $this->PrepareMenu();
	}


	public function PrepareSlogan()
	{
		$q = new Query();

		$result = $q->Select("COUNT(DISTINCT Slogan) as RowSize")->From("sansurehayir_slogan")->Where("HasPublished")->EqualTo("1")->Execute();
		foreach($result as $row)
		{
			$sloganSize = $row->rowsize;
			break;
		}

		$choser = rand(0, $sloganSize);
	
		$result = $q->Select("DISTINCT Slogan")->From("sansurehayir_slogan")->Where("HasPublished")->EqualTo("1")->Paging(1, $choser)->Execute();

		foreach($result as $row)
		{
			return $row->slogan;
		}
	}

	public function PrepareMenu()
	{
		$menuItems = Array("yapilmasi_gerekenler" => "Yapılması Gerekenler", 
						"sansurun_etkileri" => "Sansürün Etkileri",
						"hukukcu_gozuyle" => "Hukukçu Gözüyle",
						"kapanan_siteler" => "Kapanan Siteler",
						"slogan_oner" => "Slogan Öner",
						"gorseller" => "banner, sticker, flyer vb...",
						"destekleyenler" => "Destekleyenler",
						"iletisim" => "İletişim");

	
		$str = "<ul>";
		
		foreach ($menuItems as $key => $val)
		{
			$selected = ($this->Page->SiteMapPage->Filter == $key) ? "class='active'" : "";

			$str .=	"<li><a href='$key' $selected>$val</a></li>";
		}

		$str .= "</ul>";

		return $str;
	}
}




?>
